Log Analysis and Visulization

In [1]:
import utils
import os
from os import path
import pickle
import pandas as pd
In [2]:
if __name__ == "__main__":
    
    with open('./tmp/shard.pkl', 'rb') as f:
        shard = pickle.load(f)
    with open('./tmp/param.pkl', 'rb') as f:
        param = pickle.load(f)
        
    date = shard[0].iloc[0]['timestamp'].strftime("%Y-%m-%d %H:%M:%S").split()[0].replace("-","_")     
    fig_dir = "../../graphs/test_logs/ostn/" + date + "/part/"
    html_dir = "../../docs/graphs/test_logs/ostn/" + date + "/part/"
    
    data = [html_dir, fig_dir]
    for directory in data:
        if not path.exists(directory):
            try:
                os.makedirs(directory)
            except:
                print("Could not make directory")
                exit(1)
    
    utils.set_config(param)
    config = utils.config
    ## get the index of the new chain started
    index = []
    for s in shard:
        i = s[s['time_per_block'] < 0].index.tolist()   
        if len(i) == 0:
            break
        i.insert(0,0)
        i.append(len(s))
        index.append(i)
    
    if len(index) == 0:
        new = pd.concat(shard)
        new.reset_index(inplace = True, drop = True)
        utils.visualization(new, fig_dir, html_dir, config)
    else:    
        for i in range(len(index[0])-1):
            df = []
            for s in range(len(shard)):
                df.append(shard[s].iloc[index[s][i]+1:index[s][i+1]])
            new = pd.concat(df)

            fig_path = fig_dir + "chain_" + str(i) + "/"
            if not path.exists(fig_path):
                os.makedirs(fig_path)

            utils.visualization(new, fig_path, html_dir, config)
Statistics summary for shard 0
==================================
Total data points: 405
              size           gas  transaction_per_second  time_per_block
mean   2165.824691  9.264543e+04                0.006139        8.861728
std    5582.283997  6.432672e+05                0.034770        0.352701
min    1003.000000  0.000000e+00                0.000000        8.000000
25%    1160.000000  0.000000e+00                0.000000        9.000000
50%    1278.000000  0.000000e+00                0.000000        9.000000
75%    1317.000000  2.338000e+04                0.000000        9.000000
max   37276.000000  5.368708e+06                0.444444       10.000000

Statistics summary for shard 1
==================================
Total data points: 445
              size  gas  transaction_per_second  time_per_block
mean   1578.062921  0.0                     0.0        8.078652
std    5589.555048  0.0                     0.0        0.269497
min     689.000000  0.0                     0.0        8.000000
25%     689.000000  0.0                     0.0        8.000000
50%     689.000000  0.0                     0.0        8.000000
75%     689.000000  0.0                     0.0        8.000000
max   36649.000000  0.0                     0.0        9.000000

Statistics summary for shard 2
==================================
Total data points: 439
              size  gas  transaction_per_second  time_per_block
mean   1425.813212  0.0                     0.0        8.094533
std    5101.427272  0.0                     0.0        0.291927
min     688.000000  0.0                     0.0        8.000000
25%     688.000000  0.0                     0.0        8.000000
50%     689.000000  0.0                     0.0        8.000000
75%     689.000000  0.0                     0.0        8.000000
max   36648.000000  0.0                     0.0        9.000000

Statistics summary for shard 3
==================================
Total data points: 436
              size  gas  transaction_per_second  time_per_block
mean   1596.653670  0.0                     0.0        8.225917
std    5645.594806  0.0                     0.0        0.417979
min     689.000000  0.0                     0.0        8.000000
25%     689.000000  0.0                     0.0        8.000000
50%     689.000000  0.0                     0.0        8.000000
75%     690.000000  0.0                     0.0        8.000000
max   36649.000000  0.0                     0.0        9.000000

Features vs Time
PNG saved in ../../graphs/test_logs/ostn/2020_04_17/part/
==================================
HTML saved in 
HTML saved in 
HTML saved in 
HTML saved in 
HTML saved in 
HTML saved in